#include"processbar.h"
#include<unistd.h>

typedef void(*callback_t)(int);//函数指针类型

//模拟一种安装或者下载
void downLoad(callback_t cb)
{
    int total = 1000;
    int curr = 0;
    while(curr <= total)
    {
        //进行着某种下载的任务
        usleep(50000);//模拟下载花费的时间
        int rate = curr*100/total;
        cb(rate);//通过回调，展示进度
        curr += 10;//循环下载了一部分
    }
    printf("\n");
}

int main()
{
    printf("download 1: \n");
    downLoad(processbar);
    initbar();
    
    printf("download 2: \n");
    downLoad(processbar);
    initbar();

    printf("download 3: \n");
    downLoad(processbar);
    return 0;
}












